package com.todo.content.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.content.application.frontend.service.ContentClassifyAggService;
import com.todo.content.iface.frontend.ContentClassifyFrontendIface;
import com.todo.content.iface.frontend.request.ContentClassifyBaseListParam;
import com.todo.content.iface.frontend.request.QueryContentClassifyDetailByCodeParam;
import com.todo.content.iface.frontend.request.RecommendContentClassifyListParam;
import com.todo.content.iface.frontend.response.ContentClassifyBaseVO;
import com.todo.content.iface.frontend.response.ContentClassifyDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/5/17 13:57
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/content")
@Tag(name = "内容分类前台接口", description = "内容分类前台接口")
public class ContentClassifyFrontendController implements ContentClassifyFrontendIface {

    @Resource
    private ContentClassifyAggService contentClassifyAggService;

    @Override
    @Operation(summary = "分类列表")
    @PostMapping("/queryContentClassifyList")
    public BizPageResponse<ContentClassifyBaseVO> queryContentClassifyList(@RequestBody ContentClassifyBaseListParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return contentClassifyAggService.queryContentClassifyList(param);
    }

    @Override
    @Operation(summary = "推荐分类列表")
    @PostMapping("/baseRecommendContentClassifyList")
    public BizResponse<List<ContentClassifyBaseVO>> baseRecommendContentClassifyList(@RequestBody RecommendContentClassifyListParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentClassifyAggService.baseRecommendContentClassifyList(param);
    }

    @Override
    @Operation(summary = "根据分类Code查询分类详情")
    @PostMapping("/queryContentClassifyDetailByCode")
    public BizResponse<ContentClassifyDetailVO> queryContentClassifyDetailByCode(@RequestBody QueryContentClassifyDetailByCodeParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentClassifyAggService.queryContentClassifyDetailByCode(param);
    }
}
